import { env } from "process";
import { login, logout, accountAvailable, addClasses } from "../dist/index.js";
import assert from "assert";

const LOGINNAME = env["BT_USER"];
const PWD = env["BT_PASSWORD"];
const ACTIVE_ID = JSON.parse(env["BT_ACTIVE_ID"]);
const LESSON_TYPE = JSON.parse(env["BT_LESSON_TYPE"]);
const CLASSES = JSON.parse(env["BT_CLASSES"]);

async function test() {
    const account = await login(LOGINNAME, PWD);
    console.log(account);
    console.log("available:", await accountAvailable(account));
    console.log("test add classes:", await addClasses(ACTIVE_ID, LESSON_TYPE, CLASSES, account));
    await logout(account);
}

async function testLogout() {
    const account = await login(LOGINNAME, PWD);
    console.log("available:", await accountAvailable(account));
    console.log("logout...");
    await logout(account);
    console.log("logout.");
    console.log("available:", await accountAvailable(account));
    console.log("test add classes:", await addClasses(114514, 0, [0, 1], account));
}

console.log("test");
await test();

// console.log("test logout");
// await testLogout();